//
//  HGFansCell.m
//  RedWinMall
//
//  Created by HeDianZhao on 2018/8/6.
//  Copyright © 2018年 HeDianZhao. All rights reserved.
//

#import "HGFansCell.h"
#import "HGFansModel.h"

static CGFloat margin = 14;

@implementation HGFansCell {
    UIImageView *_leftImgView;
    UILabel *_infoLabel;
    UILabel *_dateLabel;
    UILabel *_fansCount;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self initSubViews];
    }
    return self;
}

- (void)setModel:(HGFansModel *)model {
    _model = model;
    
    _infoLabel.text = [NSString stringWithFormat:@"%@ | %@",model.nickName,model.levelName];
    [Utility fuwenbenLabel:_infoLabel fontNumber:[UIFont systemFontOfSize:14] andRange:NSMakeRange(0, model.nickName.length) andColor:kColorDefult];
    _dateLabel.text = model.createTimeText;
    _fansCount.text = [NSString stringWithFormat:@"他有%ld粉丝",model.amountFans];
}

- (void)initSubViews {
    
    self.selectionStyle = UITableViewCellSeparatorStyleNone;
    
    CGFloat iconH = 40 * kScale;
    
    _leftImgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mrtx"]];
    [self.contentView addSubview:_leftImgView];
    [_leftImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.left.offset(margin);
        make.size.mas_equalTo(CGSizeMake(iconH,iconH));
    }];
    
    _infoLabel = [[UILabel alloc] init];
    _infoLabel.text = @"-- | --";
    _infoLabel.textColor = kColorText;
    _infoLabel.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:_infoLabel];
    
    [_infoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_leftImgView.mas_right).offset(margin - 4);
        make.top.equalTo(_leftImgView);
    }];
    
    _dateLabel = [[UILabel alloc] init];
    _dateLabel.text = @"----";
    _dateLabel.textColor = kColorText;
    _dateLabel.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:_dateLabel];
    
    [_dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(_leftImgView);
        make.left.equalTo(_infoLabel);
    }];
    
    
    
    UIImageView *rigthImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"right_more"]];
    [self.contentView addSubview:rigthImageView];
    
    [rigthImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.right.offset(-margin);
    }];
    
    _fansCount = [[UILabel alloc] init];
    _fansCount.text = @"----";
    _fansCount.textColor = kColorText;
    _fansCount.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:_fansCount];
    
    [_fansCount mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.right.equalTo(rigthImageView.mas_left).offset(-5);
    }];
}

@end
